package component;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

import exception.NoDAOException;

public class BookServiceImpl implements IBookService {
	private IBookDao bookDao;


	public IBookDao getBookDao() {
		return bookDao;
	}

//	@Required
//	@Autowired//(required=false)不作依赖检查,默认为true
	@Resource(name="bookDao")//使@Autowired按byName的方式
	public void setBookDao(IBookDao bookDao) {
		this.bookDao = bookDao;
	}


	@Override
	public void save(Book book) throws NoDAOException {
		if (bookDao==null){
			throw new NoDAOException();
		}
		bookDao.save(book);
	}

}
